﻿package com.singlenotion.utils 
{
	/**
	 * ...
	 * @author Adam Jowett (Single Notion)
	 */
	public class Print_r
	{
		public static function printr($obj:*, $level:int = 0, $output:String = ""):*
		{
			var tabs:String = "";
			for (var i:int = 0; i < $level; i++, tabs += "t");

			for (var child:* in $obj)
			{
				$output += tabs + "["+ child + "] => " + $obj[child];

				var childOutput:String = print_r($obj[child], $level + 1);
				if (childOutput != "") $output += " {n"+ childOutput + tabs + "}";

				$output += "n";
			}

			if ($level > 20) return "";
			else if ($level == 0) trace($output); else return $output;
		}		
	}
}